Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use .files() methods from importlib.resources to find the package directory #379

Merged
merged 3 commits into from
Apr 1, 2021

Conversation

vincentsarago
Copy link
Member

closes #376

let's embrace the future @kylebarron and depends on features that were added in python 3.9 😄

summary

  • in use importlib.resources to find the cmap_data directory #370 we switched to importlib.resources.path() to find the path for rio_tiler/cmap_data.
  • ☝️ worked in python 3.7 and 3.8 ... but failed in 3.9. The docs did mention that the second argument of path() had to be a file ... but it worked with a directory... it's not the case anymore with 3.9
  • A new methods (.files()) was added to 3.9, and it gives the result we were hopping for.

importlib.resources.files(package)
Returns an importlib.resources.abc.Traversable object representing the resource container for the package (think directory) and its resources (think files). A Traversable may contain other containers (think subdirectories).
package is either a name or a module object which conforms to the Package requirements.
New in version 3.9.

@vincentsarago vincentsarago changed the title update .files() methods from importlib.resources to find the package directory use .files() methods from importlib.resources to find the package directory Apr 1, 2021
rio_tiler/colormap.py Outdated Show resolved Hide resolved
vincentsarago and others added 2 commits April 1, 2021 15:47
Co-authored-by: Kyle Barron <kylebarron2@gmail.com>
@vincentsarago vincentsarago merged commit 4be289b into master Apr 1, 2021
@vincentsarago vincentsarago deleted the resolveCmapDataDirectory branch April 1, 2021 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2.0.6 fails in python 3.9
2 participants